package sword_offer;

/**
 * @author Synhard
 * @version 1.0
 * @Class sword_offer.Code8
 * @Description 写一个函数，输入 n ，求斐波那契（Fibonacci）数列的第 n 项（即 F(N)）。斐波那契数列的定义如下：F(0) = 0,   F(1) = 1
 * F(N) = F(N - 1) + F(N - 2), 其中 N > 1.
 *
 * @tel 13001321080
 * @email 823436512@qq.com
 * @date 2021-03-13 14:54
 */
public class Code8 {
    public static void main(String[] args) {
        System.out.println(fib(44));
    }

    public static int fib(int n) {
        int a = 0;
        int b = 1;
        int sum;
        for (int i = 0; i < n; i++) {
            sum = a + b;
            a = b;
            b = sum;
        }
        return a;
    }
}
